package com.educate.controller;

import com.educate.pojo.Response;
import com.educate.service.ResponseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  信息回复web层
 * @author xiongyu
 * @date 2021/12/23 19:18
 */
@RestController
@RequestMapping("/response")
public class ResponseController {

    @Autowired
    private ResponseService responseService;

    /**
     * 添加问题回复
     * @param response
     * @return
     */
    @PostMapping
    public Long insertResponse(@RequestBody Response response){
      return responseService.insertResponse(response);
    }

    /**
     * 删除问题回复
     * @param responseId
     * @return
     */
    @DeleteMapping("/{responseId}")
     public Boolean deleteResponse(@PathVariable long responseId){
      return responseService.deleteResponse(responseId);
    }

    /**
     * 通过问题id 查询问题回复集合
     * @param problemId
     * @return
     */
    @GetMapping("/{problemId}")
    List<Response> queryResponseByProblemId(@PathVariable long problemId){
        return responseService.queryResponseByProblemId(problemId);
    }
}
